#ifndef __FUNC_OLED_H__
#define __FUNC_OLED_H__

	#ifdef FUNC_OLED_MAIN
	 	#define FUNC_OLED_EXT
	#else
		#define FUNC_OLED_EXT extern
	#endif
	
	#include "includes.h" 
	
		
	#define OLED_LINE_MAX DISP_LINE_N
	#define OLED_COLUMN_MAX DISP_COLUMN_N
		
		
	#define B_OLED_RST		HWREGBITW(&(GPIOB->ODR),5)		//PA11
	#define B_OLED_DC		HWREGBITW(&(GPIOB->ODR),4)		//PA12
	#define B_OLED_CS		HWREGBITW(&(GPIOB->ODR),3)		//PA8	
		
	//#define B_OLED_BL		HWREGBITW(&(GPIOC->ODR),9)		//PA8	
		
	
	//#define OLED_PA_OPP_PIN	(GPIO_Pin_8 | GPIO_Pin_11 | GPIO_Pin_12)
	#define OLED_PB_OPP_PIN	(GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5)
	//#define OLED_PC_OPP_PIN	(GPIO_Pin_9)
	
		
enum OLED_FONT
{
	OLED_FONT_8x16,
	OLED_FONT_6x8
};
		
	extern const unsigned char F6x8[][6];
	extern const unsigned char F8X16[];

enum OLED_MODE
{
	OLED_MODE_STRING8x16,
	OLED_MODE_DOT,
};
	
	typedef struct{
		unsigned char mode;
		unsigned char step;		//状态机步骤
		unsigned char cur_line;	//当前显示行
		unsigned char rev0;
		char buf[OLED_LINE_MAX][OLED_COLUMN_MAX];			//每行16个字符，一共4行
		unsigned char rev_buf[OLED_LINE_MAX][OLED_COLUMN_MAX];	//反白控制
		unsigned char lcd_dot_buf[8][128];			//点阵缓存
		
	}FUNC_OLED_T;				//周期控制LED输出结构体
		

	FUNC_OLED_EXT FUNC_OLED_T g_func_oled;

	void func_oled_Init(FUNC_OLED_T *p);
	void func_oled_msp_init(void);
	void func_oled(FUNC_OLED_T *p);
	void OLED_Disp_Str(unsigned char line,char *buf);
	void OLED_Show_Column(unsigned short x,unsigned int y,unsigned int max);
	void OLED_SetMode_String(void);
	void OLED_SetMode_Dot(void);
	void func_oled_ShowLine(FUNC_OLED_T *p,unsigned char line);
	void func_oled_ShowChinese16x16(unsigned char x,unsigned char y,unsigned short chr,unsigned char b_rev);
	


#endif
